﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link href="<%=basePath%>plugins/h_uiadmin_v2.3.4/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="<%=basePath%>plugins/h_uiadmin_v2.3.4/css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="<%=basePath%>plugins/h_uiadmin_v2.3.4/lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
<link href="<%=basePath%>plugins/h_uiadmin_v2.3.4/lib/Hui-iconfont/1.0.7/iconfont.css" rel="stylesheet" type="text/css" />
 
<title>组织机构编辑</title>
</head>
<body class="pos-r">
 
<div class="pd-20">
 <form  id="form1"   method="post" class="form form-horizontal"  >
     <c:choose>
       <c:when test='${type eq "add" }'>
	            <div class="row cl">
			      <label class="form-label col-3"><span class="c-red">*</span>父组强机构名称：</label>
			      <div class="formControls col-5">
			        <input type="text" class="input-text" value="${org.name}" placeholder="" id="parentName" name="parentName"   readonly="readonly">
			      </div>
			      <div class="col-4"> </div>
		      </div>
		       <div class="row cl">
			      <label class="form-label col-3"><span class="c-red">*</span>组强机构名称：</label>
			      <div class="formControls col-5">
			        <input type="text" class="input-text" value="" placeholder="" id="name" name="name"  datatype="*" nullmsg="名称不能为空" >
			      </div>
			      <div class="col-4"> </div>
		     </div>
		     <input id="parentId" name="parentId" type="hidden" value="${org.id}">
       </c:when>
       <c:otherwise>
             <div class="row cl">
			      <label class="form-label col-3"><span class="c-red">*</span>组强机构名称：</label>
			      <div class="formControls col-5">
			        <input type="text" class="input-text" value="${org.name}" placeholder="" id="name" name="name"  style="width:100%" >
			      </div>
		     </div>
		     <input id="id" name="id" type="hidden" value="${org.id}">
       </c:otherwise>
     </c:choose>
     
    <input type="hidden" name="type" id="type" value="${type}">
    <div class="row cl">
      <div class="col-9 col-offset-3">
        <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
        &nbsp;&nbsp;<input id="closeBtn"  class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;关闭&nbsp;&nbsp;">
      </div>
    </div>
     
	</form>
 
</div>
 
<script type="text/javascript" src="<%=basePath%>plugins/h_uiadmin_v2.3.4/lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="<%=basePath%>plugins/h_uiadmin_v2.3.4/lib/layer/2.1/layer.js"></script>
<script type="text/javascript" src="<%=basePath%>plugins/h_uiadmin_v2.3.4/lib/laypage/1.2/laypage.js"></script> 
 
<script type="text/javascript" src="<%=basePath%>plugins/h_uiadmin_v2.3.4/lib/Validform/5.3.2/Validform.min.js"></script>
<script type="text/javascript" src="<%=basePath%>plugins/h_uiadmin_v2.3.4/js/H-ui.js"></script> 
<script type="text/javascript" src="<%=basePath%>plugins/h_uiadmin_v2.3.4/js/H-ui.admin.js"></script> 
 <script type="text/javascript" src="<%=basePath%>common/js/cms.js"></script>

<script type="text/javascript"> 
 $(function(){
	
	$("#form1").Validform({
		tiptype:2,
		beforeSubmit:function(curform){
			 //在验证成功后，表单提交前执行的函数，curform参数是当前表单对象。
            //这里明确return false的话表单将不会提交;
			submitForm(curform) ;
			return false ;
		},
		callback:function(form){
			
			// submitForm(form) ;
			// form[0].submit();
			return false ;
		}
	});
	
	function submitForm(form ){
		var params = JSON.stringify( $("#form1").serializeJson()) ;
		$.ajax({
			"type": "POST", 
			"url": "<%=basePath%>orgmgr/doedit"  , 
		   // "contentType":"application/json;charset=UTF-8",   
			"dataType": "json",  // 预期服务器返回的数据类型
			"data": "params="+params ,      
			"success": function(resp) {
				// console.log(resp) ;
				if(resp.success){
					    var index = parent.layer.getFrameIndex(window.name);
					    parent.refreshNode($("#type").val() ,$("#name").val() ); 
						parent.layer.close(index);
				}else{
					layer.alert( resp.errMsg, {icon: 2},function(index){
						 layer.close(index);
					  });
				}
				 
			}
		}); 
	}
	
	
	$("#closeBtn").click(function(){
		var index = parent.layer.getFrameIndex(window.name);
		parent.layer.close(index);
	});
	
});
</script> 
</body>
</html>